package com.example.xyh.Controller;

import com.example.xyh.entity.OrderTable;
import com.example.xyh.service.OrderTableService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping
@Tag(name = "OrderTable", description = "OrderTableController")
public class OrderTableController {
    @Resource
    OrderTableService orderTableService;

    @Autowired
    public OrderTableController(OrderTableService orderTableService) {
        this.orderTableService = orderTableService;
    }


    @PostMapping("/FindOrderTableByCustomerIdShopIdOrderState")
    public List<OrderTable> findOrderTable(@RequestParam Integer customer_id, @RequestParam Integer shop_id, @RequestParam Integer order_state) {
        return orderTableService.findByCustomerIdAndShopShopIdAndOrderState(customer_id, shop_id, order_state);
    }


    @PostMapping("/ListOrderTableByCustomerId")
    public List<OrderTable> listOrderTableByCustomerId(@RequestParam Integer customer_id) {
        return orderTableService.findByCustomerId(customer_id);
    }


    @PostMapping("/AddOrderTable")
    public OrderTable addOrderTable(@RequestParam Integer order_id, @RequestParam Integer customer_id, @RequestParam Integer shop_id,
                                    @RequestParam Integer order_state, @RequestParam Double order_cost) {
        return orderTableService.addOrderTable(order_id, customer_id, shop_id, order_state, order_cost);
    }


    @PostMapping("/FindListOrderTableByShopId")
    public List<OrderTable> findListOrderTableByShopId(@RequestParam Integer shop_id) {
        return orderTableService.findByShopShopId(shop_id);
    }
}
